//package com.yuanhao.securitydemo.config;
//
//import org.springframework.beans.factory.annotation.Configurable;
//import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
//import org.springframework.security.config.annotation.web.builders.HttpSecurity;
//import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
//
//@Configurable
//public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
//
//    //设置内存用户
//    @Override
//    protected void configure(AuthenticationManagerBuilder auth) throws Exception {
//        //配置内存中的 用户名、密码和角色
//        auth.inMemoryAuthentication()
//                .withUser("")
//                .password("").roles("","")
//                .and()
//                .withUser("")
//                .password("").roles("")
//                .and()
//                .passwordEncoder(new MyPasswordEncoder());
//    }
//
//    //设置登录拦截和权限认证
//    @Override
//    protected void configure(HttpSecurity http) throws Exception {
//        http.authorizeRequests()
//                .antMatchers("/login").permitAll()
//                .antMatchers("/user").hasRole("USER") //访问 /user这个接口，需要有USER角色
//                .antMatchers("/admin").hasRole("ADMIN")
//                .anyRequest().authenticated() //剩余的其他接口，登录之后就能访问
//                .and()
//                .formLogin().defaultSuccessUrl("/hello");
//    }
//}
